package src.main.java.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import src.main.java.service.FileUploadService;
import vo.common.vo.common.Result;
import vo.common.vo.common.ResultCodeEnum;

/**
 * ***** 头像上传、图片接口 -minio
 *
 *      其实就是利用minio插件，存储后将url返回给前端
 *      利用spring的MultipartFile获取文件
 *
 *
 * @author zm_ya
 */
@Tag(name = "图片接口")
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService ;

    @PostMapping(value = "/fileUpload")
    public Result<String> fileUploadService(@RequestParam(value = "file") MultipartFile file) {
        String fileUrl = fileUploadService.fileUpload(file) ;
        return Result.build(fileUrl , ResultCodeEnum.SUCCESS) ;
    }

}